
/* JavaScript content from js/loading.js in folder common */


(function($){
	
	$("#loading").on('pageshow',function(){	
		getDriInfo();
				
	});
	$("#cancelButton").on("click", cancelRequest);
	

	
})(jQuery);

function getDriInfo(){
//	var latitude=window.customer.latitude;
//	var longitude=window.customer.longitude;
//	var cus_id=window.customer.id;
	var latitude=31.202818;
	var longitude=121.557706;
	var cus_id=123;
	var invocationData = {

			adapter : 'stAdp',
			procedure : 'getDriverInfo',
			parameters : [{'cus_lat': latitude,'cus_lng':longitude,'cus_id':cus_id, 'cus_option':window.custOption}],
		};
	WL.Client.invokeProcedure(invocationData,{
		timeout:10000,
		onSuccess : getDriInfoSuccess,
		onFailure : getDriInfoFailure
	});
}

function getDriInfoSuccess(result){
	alert("success");
	window.backResult=result.invocationResult;
	window.backResult.driverInfo=result.invocationResult.dri_info;
	if(window.backResult.status==0){
		window.page=1;
	    $.mobile.changePage("../view/customer-main.html");	
	}else if(window.backResult.status==1){
	    $.mobile.changePage("nodriver.html", {
				role: "dialog"
		});
	}else{
		WL.Logger.error("request fail!");
	}	
	
}

function getDriInfoFailure(result){
	alert("fail");
	//alert(JSON.stringfy(result)+"fail");
	if(result.invocationResult.status==1){
		$.mobile.changePage("nodriver.html", {
				role: "dialog"
		});
	}else{
		WL.Logger.error("Feed retrieve failure");
	}
}
